How to fix the NGINX error "Failed to read PID from file", quick and easy | 您所在的位置:网站首页 › nginx reload invalid pid › How to fix the NGINX error "Failed to read PID from file", quick and easy |
Here’s a tip on how to fix the error message: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argumentquick and easy. This fix should do it for you. This behavior is a known bug, caused by a race condition between nginx and systemd. Systemd is expecting the PID file to be populated before nginx had the time to create it. To fix the error, you have basically two options. Option 1: create the PID fileTo fix the error, you have to create the PID file manually. Step 1. Create the directory /etc/systemd/system/nginx.service.dCreate a directory named nginx.service.d in /etc/systemd/system/: mkdir /etc/systemd/system/nginx.service.dShould the system complain that it already exists, ignore and move on to Step 2. Step 2. Print data to fileExecute: printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.confThis is a one-liner. printf will write its output into the configuration file /etc/systemd/system/nginx.service.d/override.conf. Step 3. Reload the daemonReload systemd manager configuration: systemctl daemon-reloadThis will rerun all generators, reload all unit files and recreate the entire systemd dependency tree. Step 4. Restart NGINXThis line will restart NGINX for you: systemctl restart nginxThe error should be fixed now. Option 2: an alternative workaroundAnother workaround is removing the PIDFile option and adding the line: ExecStopPost=/bin/rm -f /run/nginx.pid
You can find the full documentation of this bug at: https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864If you experience this problem, SELinux could be preventing php-fpm from accessing a port. Just a hint. Try journalctl -xefor guidance on your next steps. |
CopyRight 2018-2019 实验室设备网 版权所有 |